package com.img.shop.controller;

import com.img.shop.pojo.User;
import com.img.shop.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
class LoginController {
    @Autowired
    LoginService loginService;

    //ResponseBody默认编码是iso-8859-1，响应中文全？
    //使用produces = "application/json; charset=utf-8"即可解决
    @org.springframework.web.bind.annotation.ResponseBody
    @RequestMapping(value = "/login", produces = "application/json; charset=utf-8")
    public String login(User user){
        boolean flag = loginService.login(user);
        if(flag){
            return "登陆成功";
        }
        return "登陆失败";
    }
}